%%% -------------------------------------------------------------------
%%%
%%% http://www.9miao.com
%%% -------------------------------------------------------------------
%%% -------------------------------------------------------------------
%%% Author  : adrian
%%% Description :
%%%
%%% Created : 2010-7-14
%%% -------------------------------------------------------------------
-module(dbsup).

-behaviour(supervisor).
%% --------------------------------------------------------------------
%% Include files
%% --------------------------------------------------------------------

%% --------------------------------------------------------------------
%% External exports
%% --------------------------------------------------------------------
-export([]).

%% --------------------------------------------------------------------
%% Internal exports
%% --------------------------------------------------------------------
-export([
	 init/1,
	 start_master/0,
	 start_line_db_master/0,
	 start_dal_dmp/0
        ]).

%% --------------------------------------------------------------------
%% Macros
%% --------------------------------------------------------------------
-define(SERVER, ?MODULE).

%% --------------------------------------------------------------------
%% Records
%% --------------------------------------------------------------------

%% ====================================================================
%% External functions
%% ====================================================================

start_master()->
	supervisor:start_link({local,?MODULE}, ?MODULE, [master]).

start_line_db_master()->
	supervisor:start_link({local,?MODULE}, ?MODULE, [line_db_master]).

start_dal_dmp()->
	supervisor:start_link({local,?MODULE}, ?MODULE, [dal_dmp]).

%% ====================================================================
%% Server functions
%% ====================================================================
%% --------------------------------------------------------------------
%% Func: init/1
%% Returns: {ok,  {SupFlags,  [ChildSpec]}} |
%%          ignore                          |
%%          {error, Reason}
%% --------------------------------------------------------------------
init([DbType]) ->
	case DbType of
		master->
			AChildList = [{dbmaster,{dbmaster,start_link,[]}, permanent,2000,worker,[dbmaster]}];
		dal_dmp->
			 AChildList = [{dal_dmp,{dal_dmp,start_link,[]}, permanent,2000,worker,[dal_dmp]}];
		line_db_master->
			AChildList = [{line_db_master,{line_db_master,start_link,[]}, permanent,2000,worker,[line_db_master]}]			              
	end,
    {ok,{{one_for_all,10,10}, AChildList}}.

%% ====================================================================
%% Internal functions
%% ====================================================================

